package net.ext.os;

import java.lang.management.ManagementFactory;
import java.util.List;
import java.util.Map;

import cn.hutool.core.util.RuntimeUtil;
import fx.web.biz.LinuxBiz;
import fx.web.biz.WindowsBiz;
import fx.web.ctrl.pojo.UpdSerProInfo;
import net.alche.al.util.AC;

public class OsWindowUtil {
  static String linuxRsult = """
      COMMAND     PID USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
      AliYunDun  4769 root    9u  IPv4 313218172      0t0  TCP iZ0jl1v0pbm6tnj5mr1qgwZ:56828->100.100.30.28:http (ESTABLISHED)
      java      13086 root   42u  IPv6 311380819      0t0  TCP *:http (LISTEN)

      {"v6":"0t0","v7":"TCP","v8":"iZ0jl1v0pbm6tnj5mr1qgwZ:56828-\u003e100.100.30.28:http"
        ,"v9":"(ESTABLISHED)","v0":"AliYunDun"
        ,"v1":"4769","v2":"root","v3":"9u","v4":"IPv4","v5":"313218172"}
      , {"v6":"0t0","v7":"TCP","v8":"*:http"
        ,"v9":"(LISTEN)","v0":"java"
        ,"v1":"19675","v2":"root","v3":"42u","v4":"IPv6","v5":"314717204"}
      """;

  public OsWindowUtil() {
    ManagementFactory.getRuntimeMXBean();
  }

  public static void mainxx(String[] args) throws Exception {
    LinuxBiz biz = new LinuxBiz();
    List<Map> mpLst = biz.parseKvs(linuxRsult, false);
    AC.log(mpLst);

    // WindowsBiz biz = new WindowsBiz();
    // UpdSerProInfo pro = new UpdSerProInfo();
    // pro.tomcatPort = "92";
    // pro.tomcatRoot = "E:\\tom9-crm";
    // biz.restart(pro);
  }

}
